
import 'package:flutter/material.dart';

void main() =>runApp(MyApp());

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context){
    return MaterialApp(
        home:HYHomePage()
    );
  }
}

class HYHomePage extends StatelessWidget {
  @override
  Widget build(BuildContext context){
    return Scaffold(
      appBar: AppBar(
        title: Text("基础widget"),
      ),
      body:HYHomeContent(),
    );
  }
}

class HYHomeContent extends StatefulWidget {
  const HYHomeContent({super.key});

  @override
  State<HYHomeContent> createState() => _HYHomeContentState();
}
/**
 * 编辑器快捷键配置
 * preferences>keymap>找到冲突的快捷键extract，修改快捷键
 *alt+z抽取成一个widget
 *
 */
class _HYHomeContentState extends State<HYHomeContent> {
  final imageURL ="https://t7.baidu.com/it/u=2638406194,523661981&fm=193&f=GIF";
  @override
  Widget build(BuildContext context) {
    return ImageDemo02();
  }
}

class ImageDemo02 extends StatelessWidget {
  const ImageDemo02({
    super.key,
  });

  @override
  Widget build(BuildContext context) {
    return Image(
      //1、在Flutter项目中创建一个文件夹，存储图片
      //2、在pubspec.yaml进行配置
      //使用图片
        image: AssetImage("assets/images/pic.png")
    );
  }
}

class ImageDemo01 extends StatelessWidget {
  const ImageDemo01({
    super.key,
    required this.imageURL,
  });

  final String imageURL;

  @override
  Widget build(BuildContext context) {
    return Image(
      image: NetworkImage(imageURL),
      width: 200,
      height: 200,
      fit:BoxFit.fitWidth,
      alignment: Alignment(0,-2),
      color: Colors.red,
    );
  }
}
